package com.sr.examination.other;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.sr.examination.R;
import com.sr.examination.net.Net;
import com.tl.commonlibrary.network.ErrorResponse;
import com.tl.commonlibrary.network.RequestListener;
import com.tl.commonlibrary.network.bean.base.BaseBean;
import com.tl.commonlibrary.ui.beans.NewsBean;
import com.tl.commonlibrary.ui.web.WebActivity;
import com.tl.commonlibrary.ui.web.WebModel;

import retrofit2.Call;

/**
 * Created by JongSung on 18/3/14.
 */

public class HelpActivity extends WebActivity {
    public static void start(Context context) {
        Intent intent = newIntent(context, context.getString(R.string.main_menu_guide), WebModel.FROM_TYPE_DEFAULT);
        intent.setClass(context, HelpActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getHelp();
    }

    private void getHelp() {
        showLoading();
        Net.getHelp(new RequestListener<BaseBean<NewsBean>>() {
            @Override
            public void onSuccess(Call<BaseBean<NewsBean>> call, BaseBean<NewsBean> response) {
                if (response.isSuccessful()) {
                    loadHtml(response.data.getContent());
                }
                dismissAll();
            }

            @Override
            public void onFailed(Call<BaseBean<NewsBean>> call, ErrorResponse errorResponse) {
                dismissAll();
            }
        });
    }
}
